package com.diver.flinkdemo.service.impl;/**
 * @author yangs
 */


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.diver.flinkdemo.entity.xxt.FamilyMobile;
import com.diver.flinkdemo.mapper.mysqlMapper.IFamilyMobileMapper;
import com.diver.flinkdemo.service.IFamilyMobileService;
import com.diver.flinkdemo.utils.DynamicDataSourceUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.SqlSession;

/**
 * @author yangs
 */
//@Service
@Slf4j
public class FamilyMobileService implements IFamilyMobileService {

    private IFamilyMobileMapper mapper;
    private SqlSession session;
    @Override
    public void clearFamilyMobile(String stuId) {
        try {
            session = DynamicDataSourceUtil.mysqlSessionFactory.openSession();
            mapper = session.getMapper(IFamilyMobileMapper.class);
            mapper.delete(new QueryWrapper<FamilyMobile>().eq("imei", stuId));
        } finally {
            endOfSession(session);
        }
    }

    public void endOfSession(SqlSession session) {
        //关闭sqlSession
        if (session != null) {
            log.info("session commit -> session close");
//            session.commit();
            session.close();
        }
    }
}
